<template>
  <tr>
    <td><input type="checkbox" v-model="item.checked" /></td>
    <td>
      <span>{{ item.name }}</span>
    </td>
    <td>
      <span>{{ item.price }}</span>
    </td>
    <td>
      <button @click="addFn">+</button><span>{{ item.num }}</span
      ><button @click="subFn">-</button>
    </td>
    <td>{{ item.price * item.num }}</td>
    <td><button @click="DelFn">删除</button></td>
  </tr>
</template>

<script>
export default {
  props: {
    item: Object,
    ind: Number,
  },
  methods: {
    addFn() {
      this.item.num++
    },
    subFn() {
      if (this.item.num > 1) this.item.num--
    },
    DelFn() {
      this.$emit("delEvent", this.ind)
    },
  },
}
</script>

<style></style>
